<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui" 
        xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Movie Web Service</title>
    </h:head>
    <h:body rendered="#{userService.currentUser.isLoggedIn}" >
        <h:form id="form11">
            <p:commandButton value="Add Movie" action="addmovie.jsf" />
            <p:commandButton value="Add Movie For All" action="#{userService.easyAccesstoAddMovie}" />
            <p:commandButton value="Edit Movies" action="editmovie.jsf" />
            <p:commandButton value="Edit Movies For All" action="#{userService.easyAccessToEditMovie}" />
            <p:commandButton value="Upload" action="upload.jsf" />
            <p:commandButton value="Logout" actionListener="#{userService.logout()}" />
            <!--<p:commandButton value="List Movies" action="allmovies.jsf" />-->
        </h:form>
        <br/>
        <h:form id="form12">
        <table >
            <tr align="center">
                <td colspan="2" >
                    <h2>Search</h2>
                </td>
            </tr>
            <tr align="center">
                <td colspan="2">
                    <p:inputText value="#{movieService.searchQuery}" id="title" />
                </td>
            </tr>
            <tr align="center">
                <td>
                    <p:commandButton value="Search (Worse)" update="panel1" action="#{movieService.getMovieByTitle()}" id="submit" />
                </td>
                <td>
                    <p:commandButton value="Search (Better)" update="panel1" action="#{movieService.getMovieByTitle2()}" id="submit2" />
                </td>
            </tr>
            <tr >
                <td colspan="2">
                <table>
                <p:panel id="panel1" header="Results" style="margin-top:20px;" >
                    <p:dataList value="#{movieService.movies}" var="movie"  >
                        <tr>
                            <td>
                                #{movie.id}:
                            </td>
                            <td>
                                #{movie.title}
                            </td>
                            <td>
                                #{movie.genre}, 
                            </td>
                            <td>
                                #{movie.releaseYear}
                            </td>
                        </tr> 
                    </p:dataList>
                <p:outputLabel value="#{movieService.message1}" />
                </p:panel>
                </table>
                </td><!--
                <td>
                <table>
            <p:panel id="panel2" header="Results" style="margin-top:20px;" >
                    <p:dataList value="#{movieService.movies2}" var="movie"  >
                        <tr>
                            <td>
                                #{movie.id} - 
                            </td>
                            <td>
                                #{movie.title}, 
                            </td>
                            <td>
                                #{movie.genre}, 
                            </td>
                            <td>
                                #{movie.releaseYear}
                            </td>
                        </tr> 
                    </p:dataList>
                <p:outputLabel value="#{movieService.message2}" />
            </p:panel>
                </table>
                </td>-->
            </tr>
        </table>
        </h:form>
    </h:body>
    <h:body rendered="#{userService.currentUser.isLoggedIn == false}">
        You're not allowed to be on this page, while not being logged in!
        <br/>
        <h:form>
            <p:commandLink id="redirectlink" action="index.jsf" >Log in</p:commandLink>
        </h:form>
    </h:body>
</html>

